<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="images/reset.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<link href="images/system.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />  
<link href="images/table_form.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet" type="text/css" />
<script src="{yun:}$config.sy_weburl{/yun}/js/jquery-1.8.0.min.js?v={yun:}$config.cachecode{/yun}"></script>
<script src="js/admin_public.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<link href="{yun:}$config.sy_weburl{/yun}/js/layui/css/layui.css?v={yun:}$config.cachecode{/yun}" rel="stylesheet">
<script src="{yun:}$config.sy_weburl{/yun}/js/layui/layui.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$config.sy_weburl{/yun}/js/layui/phpyun_layer.js?v={yun:}$config.cachecode{/yun}"></script>

<title>后台管理</title>
</head>
<body class="body_ifm">
<div class="infoboxp">
<div class="admin_new_tip">
<a href="javascript:;" class="admin_new_tip_close"></a>
<a href="javascript:;" class="admin_new_tip_open" style="display:none;"></a>
<div class="admin_new_tit"><i class="admin_new_tit_icon"></i>操作提示</div>
<div class="admin_new_tip_list_cont">
<div class="admin_new_tip_list">添加广告位时，请正确选择广告分类和消费类型。</div>
</div>
</div>
<div class="clear"></div>
  <div class="tag_box mt10">
  <form class="layui-form">
   <input type="hidden" name="pytoken" id="pytoken" value="{yun:}$pytoken{/yun}">
    <table width="100%" class="table_form">
        <tbody>
      <tr class="ui_td_11" >
        <th width="80">类别名称：</th>
        <td><div><input type="text" name="add_name" value="{yun:}$info.class_name{/yun}" id="class_name" class="input-text" /></div></td>
      </tr>
      <tr class="ui_td_11">
        <th>排  序：</th>
        <td><input type="text" name="orders" id='orders' size='5'  value="{yun:}$info.orders{/yun}" class="input-text" onKeyUp="this.value=this.value.replace(/[^0-9]/g,'')"/></td>
      </tr>
      <tr class="ui_td_11">
        <th>广告类型：</th>
        <td> 
            <div class="layui-form-item">
              <div class="layui-input-block">
                 <div class="layui-input-inline">
                   <input type="radio" value='1'  name="type" id="type_1" title="可购买" lay-filter="type" {yun:}if $info.type==1{/yun}checked{yun:}/if{/yun}>
                   <input type="radio" value='2'  name="type" id="type_2" title="不可购买" lay-filter="type" {yun:}if $info.type==2{/yun}checked{yun:}/if{/yun}>
                 </div>
               </div>
            </div></td>
      </tr>
	  <tr class="ui_td_11 btype" {yun:}if $info.type!=1{/yun}style="display:none"{yun:}/if{/yun}>
        <th>消费类型：</th>
        <td> 
            <div class="layui-form-item">
              <div class="layui-input-block">
                 <div class="layui-input-inline">
                   <input type="radio" value='1'  name="btype" id="btype_1" title="{yun:}$config.integral_pricename{/yun}" lay-filter="btype" {yun:}if $info.btype==1{/yun}checked{yun:}/if{/yun}>
                   <input type="radio" value='2'  name="btype"  id="btype_2" title="金额" lay-filter="btype" {yun:}if $info.btype==2{/yun}checked{yun:}/if{/yun}>
                 </div>
               </div>
            </div></td>
      </tr>
      <tr class="ui_td_11 buy" {yun:}if $info.type!=1{/yun}style="display:none"{yun:}/if{/yun}>
        <th>购买费用：</th>
        <td><input id="integral_buy" class="input-text" type="text" size="5" onKeyUp="value=this.value.replace(/\D+/g,'')" value="{yun:}$info.integral_buy{/yun}" name="integral_buy">
         <span> {yun:}if $info.btype==2{/yun}元{yun:}else{/yun}{yun:}$config.integral_pricename{/yun}{yun:}/if{/yun}</span>/月 </td>
      </tr>
      <tr class="ui_td_11 buy" {yun:}if $info.type!=1{/yun}style="display:none"{yun:}/if{/yun}>
        <th>所在位置：</th>
        <td>
			<button type="button" class="yun_bth_pic adminupload" lay-data="{name: 'href',imgid: 'imgicon'}">上传图片</button>
			
			<input type="hidden" id="layupload_type" value="2"/>
			<input type="hidden" id="upload_path" value="ad"/>

			<input type="hidden" name="href" id="href" value="{yun:}$info.href{/yun}"/>
			<img  id="imgicon" {yun:}if !$info.hrefn{/yun}class="none"{yun:}/if{/yun} src='{yun:}$info.hrefn{/yun}' width="100" height="50"/>
		</td>
      </tr>
	  <tr class="ui_td_11 buy" {yun:}if $info.type!=1{/yun}style="display:none"{yun:}/if{/yun}>
        <th>广告宽度：</th>
        <td><input id="x" class="input-text" type="text"  value="{yun:}$info.x{/yun}" name="x"> px(像素)</td>
      </tr>
	  <tr class="ui_td_11 buy" {yun:}if $info.type!=1{/yun}style="display:none"{yun:}/if{/yun}>
        <th>广告高度：</th>
        <td><input id="y" class="input-text" type="text"  value="{yun:}$info.y{/yun}" name="y">
           px(像素)</td>
      </tr>
	   <tr class="ui_td_11 buy" {yun:}if $info.type!=1{/yun}style="display:none"{yun:}/if{/yun}>
        <th>备注说明：</th>
        <td><textarea id="remark" class="input-text" name="remark">{yun:}$info.remark{/yun}</textarea>
        </td>
      </tr>
      <tr class="ui_td_11">
        <input name='id' value='{yun:}$info.id{/yun}' type='hidden' id='id'/>
        <td  class="ui_content_wrap" colspan='2'>
		<input class="layui-btn layui-btn-normal" type="button" name="add" value="&nbsp;提  交&nbsp;" onclick="save_adclass()"/>
        <input class="layui-btn layui-btn-normal" type="reset" name="reset" value="&nbsp;重 置 &nbsp;" /></td>
      </tr>
    </tbody>
    </table>
  </form>
</div></div>
<script type="text/javascript">
var weburl = '{yun:}$config.sy_weburl{/yun}';
layui.use(['layer', 'form'], function(){
    var layer = layui.layer
    ,form = layui.form
    ,$ = layui.$;
	form.on('radio(type)', function(data){
		if(data.value=='1'){
			$('.btype').show();
			$('.buy').show();
		}else{
			$('.btype').hide();
			$('.buy').hide();
		}
		form.render();
	}); 
	form.on('radio(btype)', function(data){
		if(data.value=='1'){
			$('.buy span').html('{yun:}$config.integral_pricename{/yun}');
		}else{
			$('.buy span').html('元');
		}
		form.render();
	});
});
function save_adclass(){
	var id=$("#id").val(); 
	var class_name=$("#class_name").val(); 
	var orders=$("#orders").val();
	var pytoken=$("#pytoken").val();
	var integral_buy=$("#integral_buy").val();
	var type=$('input[name="type"]:checked').val();
	var btype=$('input[name="btype"]:checked').val();
	var href=$('#href').val();
	var x=$("#x").val();
	var y=$("#y").val();
	var remark=$("#remark").val();
	if($.trim(class_name)==''){
		parent.layer.msg('广告类别名称不能为空！', 2,8);return false;
	}
	if(type!=1&&type!=2){
		parent.layer.msg('请选择广告类型！', 2,8);return false;
	}
	if(type=='1'){
		if(btype!=1&&btype!=2){
			parent.layer.msg('请选择消费模式！', 2,8);return false;
		}else{
			if(btype=='1'&&integral_buy==''){
				parent.layer.msg('请输入购买{yun:}$config.integral_pricename{/yun}！', 2,8);return false;
			}else if(btype=='2'&&integral_buy==''){
				parent.layer.msg('请输入购买金额！', 2,8);return false;
			}
		}
		if(x==''){
			parent.layer.msg('请填写广告宽度！', 2,8);return false;
		}
		if(y==''){
			parent.layer.msg('请填写广告高度！', 2,8);return false;
		}
	}
	loadlayer();
	$.post("index.php?m=advertise&c=addclass",{class_name:class_name,orders:orders,integral_buy:integral_buy,type:type,btype:btype,href:href,x:x,y:y,remark:remark,id:id,pytoken:pytoken},function(msg){
    parent.layer.closeAll('loading');
 		if(msg==1){
			parent.layer.msg('提交成功！', 2,9,function(){location='index.php?m=advertise&c=class';});return false;
		}else{
			parent.layer.msg('提交失败！', 2,8,function(){location=location ;});return false;
		}
	});
}
</script>
<script src="{yun:}$config.sy_weburl{/yun}/js/layui.upload.js?v={yun:}$config.cachecode{/yun}" type='text/javascript'></script> 
</body>
</html>